import React from 'react';
import './map.scss';
import { api } from 'js/api/api';
import { browserHistory } from 'react-router';
import { userData } from 'js/core/userData';
import Progress from 'views/component/progress/progress';
import Button from 'views/component/button/button';
import { observer, inject } from 'mobx-react';

@inject('playerStore')
@observer
class Main extends React.Component {
    changeMap = (mapType, mapName) => {
        api('changeMap', { mapType: mapType }, (err, data) => {
            if (err === 0) {
                if (data && data.log) {
                    window.eventHandle.emit('log', data.log);
                }
                this.setState({})
                browserHistory.push(mapName)
            }
        })
    }
    render() {
        return (
            <div id="map" className="">
                <div className="home-button home" onClick={() => this.changeMap(3, '/town')}>冒险者营地</div>
                <div className="map-button map-180001" onClick={() => this.changeMap(5, '/maze')}>
                    <div className="name">黑色深林</div>
                    <div className="info">1-5级</div>
                </div>
            </div>
        )
    }
}

export default Main;